﻿package base.component
{
    import flash.display.*;
    import flash.geom.*;
    import flash.text.*;

    public class LinearLabel extends Sprite
    {
        private var _maskLabel:TextField;
        private var _bg:Shape;
        private var _colors:Array;
        private var _alphas:Array;
        private var _radios:Array;
        private var _labelShape:Bitmap;

        public function LinearLabel(param1:int, param2:int, param3:Array, param4:Array, param5:Array)
        {
            this._maskLabel = new TextField();
            this._bg = new Shape();
            this._labelShape = new Bitmap();
            this._colors = param3;
            this._alphas = param4;
            this._radios = param5;
            this._maskLabel.selectable = false;
            this._maskLabel.background = false;
            this._maskLabel.width = param1;
            this._maskLabel.height = param2;
            this.addChild(this._labelShape);
            return;
        }// end function

        public function get label() : TextField
        {
            return this._maskLabel;
        }// end function

        public function set textFormat(param1:TextFormat) : void
        {
            this._maskLabel.defaultTextFormat = param1;
            return;
        }// end function

        public function set text(param1:String) : void
        {
            this._maskLabel.text = param1;
            return;
        }// end function

        public function draw() : void
        {
            var _loc_1:* = new BitmapData(this._maskLabel.width, this._maskLabel.height, true, 0);
            _loc_1.draw(this._maskLabel);
            this._bg.graphics.clear();
            var _loc_2:* = new Matrix();
            _loc_2.createGradientBox(this._maskLabel.width, this._maskLabel.height, Math.PI / 2);
            this._bg.graphics.beginGradientFill(GradientType.LINEAR, this._colors, this._alphas, this._radios, _loc_2);
            this._bg.graphics.drawRect(0, 0, this._maskLabel.width, this._maskLabel.height);
            this._bg.graphics.endFill();
            var _loc_3:* = new BitmapData(this._maskLabel.width, this._maskLabel.height, true, 0);
            _loc_3.draw(this._bg, null, null, null, null, true);
            _loc_3.copyChannel(_loc_1, new Rectangle(0, 0, this._maskLabel.width, this._maskLabel.height), new Point(), BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
            this._labelShape.bitmapData = _loc_3;
            _loc_1.dispose();
            return;
        }// end function

        public function dispose() : void
        {
            if (this._bg)
            {
                this._bg.graphics.clear();
            }
            this._bg = null;
            this._maskLabel = null;
            if (this._labelShape)
            {
                this._labelShape.bitmapData.dispose();
            }
            this._labelShape = null;
            return;
        }// end function

    }
}
